﻿using HamcoWcs.Contract.ContractPcon.IPconDbMsgParsers;
using HamcoWcs.Models.Common.Enums;
using HamcoWcs.Models.Devices;
using HamcoWcs.Service.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HamcoWcs.Service.Pcon.PconPlcDbMsgParsers
{
    [AutoInject(typeof(IPconMsgParseFactory), InjectType.Scope)]
    public class PconMsgParseFactory : IPconMsgParseFactory
    {
        private readonly IEnumerable<IBasePconParser> _pconParsers;
        public PconMsgParseFactory(IEnumerable<IBasePconParser> pconParsers)
        {
            _pconParsers = pconParsers;
        }
        public IBasePconParser CreateParser(PconDto  pconDto)
        {
            return _pconParsers.FirstOrDefault(x => (int)x.RequestType == pconDto.Request);
        }
    }
}
